namespace SmartSoft.SystemForms
{
    using SmartSoft;
    using SmartSoft.Controls;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Globalization;
    using System.Windows.Forms;

    public class FormCalculator : FormControl
    {
        private BtnControl btnButtonF01;
        private BtnControl btnButtonF02;
        private BtnControl btnButtonF03;
        private BtnControl btnButtonF04;
        private BtnControl btnButtonF05;
        private BtnControl btnButtonF06;
        private BtnControl btnButtonF07;
        private BtnControl btnButtonF08;
        private BtnControl btnButtonF09;
        private BtnControl btnButtonF10;
        private BtnControl btnButtonF11;
        private BtnControl btnButtonF12;
        private BtnControl btnButtonF13;
        private BtnControl btnButtonN00;
        private BtnControl btnButtonN01;
        private BtnControl btnButtonN02;
        private BtnControl btnButtonN03;
        private BtnControl btnButtonN04;
        private BtnControl btnButtonN05;
        private BtnControl btnButtonN06;
        private BtnControl btnButtonN07;
        private BtnControl btnButtonN08;
        private BtnControl btnButtonN09;
        private BtnControl btnButtonN10;
        private IContainer components;
        private bool ib_CheckFunction;
        public bool ib_Disposed;
        private decimal idec_CurrentNumber;
        private decimal idec_MemoryNumber;
        private LabelControl lblMemo;
        private LabelControl lblSign;
        private object oCurrentControl;
        private Panel pnlTextbox;
        private TextNumeric txtNumber;

        public FormCalculator()
        {
            this.InitializeComponent();
            base.Top = (AppInstance.CalculatorTopPosition < 0) ? 0 : AppInstance.CalculatorTopPosition;
            base.Left = (AppInstance.CalculatorLeftPosition < 0) ? 0 : AppInstance.CalculatorLeftPosition;
            this.txtNumber.NumericPrecision = AppInstance.NumberDigits;
            this.txtNumber.NumericScaleOnFocus = AppInstance.FCAmountDecimals;
            this.txtNumber.NumericScaleOnLostFocus = AppInstance.FCAmountDecimals;
            this.txtNumber.SelectionStart = this.txtNumber.Text.IndexOf(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator);
        }

        private void AllFunction(string ps_Signal)
        {
            this.pnlTextbox.BackColor = Color.Black;
            this.txtNumber.BackColor = Color.Black;
            this.txtNumber.ForeColor = Color.White;
            this.lblSign.BackColor = Color.Black;
            this.lblSign.ForeColor = Color.White;
            try
            {
                if ((!(this.idec_CurrentNumber != 0M) || !(this.txtNumber.NumericValue != 0M)) || this.ib_CheckFunction)
                {
                    goto Label_01A0;
                }
                string text = this.lblSign.Text;
                if (text == null)
                {
                    goto Label_017C;
                }
                if (!(text == "+"))
                {
                    if (text == "-")
                    {
                        goto Label_00F8;
                    }
                    if (text == "x")
                    {
                        goto Label_0116;
                    }
                    if (text == "\x00f7")
                    {
                        goto Label_0134;
                    }
                    goto Label_017C;
                }
                this.idec_CurrentNumber += this.txtNumber.NumericValue;
                goto Label_018D;
            Label_00F8:
                this.idec_CurrentNumber -= this.txtNumber.NumericValue;
                goto Label_018D;
            Label_0116:
                this.idec_CurrentNumber *= this.txtNumber.NumericValue;
                goto Label_018D;
            Label_0134:
                if (this.txtNumber.NumericValue != 0M)
                {
                    this.idec_CurrentNumber /= this.txtNumber.NumericValue;
                }
                else
                {
                    this.lblMemo.Text = "E";
                }
                goto Label_018D;
            Label_017C:
                this.idec_CurrentNumber = this.txtNumber.NumericValue;
            Label_018D:
                this.txtNumber.NumericValue = this.idec_CurrentNumber;
                goto Label_01C6;
            Label_01A0:
                this.idec_CurrentNumber = this.txtNumber.NumericValue;
            }
            catch
            {
                this.lblMemo.Text = "E";
            }
        Label_01C6:
            if (ps_Signal.Contains("="))
            {
                this.lblSign.Text = "";
            }
            this.ib_CheckFunction = true;
        }

        private void AnyKeyPressed(Button btnButton)
        {
            btnButton.Focus();
            this.pnlTextbox.BackColor = Color.White;
            this.txtNumber.BackColor = Color.White;
            this.txtNumber.ForeColor = Color.Black;
            this.lblSign.BackColor = Color.White;
            this.lblSign.ForeColor = Color.Black;
            if (base.ActiveControl is TextBox)
            {
                if (this.ib_CheckFunction)
                {
                    this.ib_CheckFunction = false;
                    this.txtNumber.Text = "0";
                    this.txtNumber.SelectionStart = this.txtNumber.Text.IndexOf(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator);
                }
            }
            else
            {
                bool flag = false;
                if (this.ib_CheckFunction)
                {
                    this.ib_CheckFunction = false;
                    flag = true;
                    this.txtNumber.Text = "0";
                    this.txtNumber.SelectionStart = this.txtNumber.Text.IndexOf(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator);
                }
                if ((this.txtNumber.SelectionLength == this.txtNumber.Text.Length) || ((this.txtNumber.SelectionStart == 0) && (this.txtNumber.NumericValue == 0M)))
                {
                    this.txtNumber.SelectionStart = this.txtNumber.Text.IndexOf(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator);
                    flag = true;
                }
                int selectionStart = this.txtNumber.SelectionStart;
                if (btnButton.Text.Equals("-"))
                {
                    if (this.txtNumber.Text.Contains("-"))
                    {
                        this.txtNumber.Text.Substring(1);
                        this.txtNumber.SelectionStart = selectionStart - 1;
                    }
                    else
                    {
                        this.txtNumber.Text = "-" + this.txtNumber.Text;
                        this.txtNumber.SelectionStart = selectionStart + 1;
                    }
                }
                else if (!this.txtNumber.Text.Contains(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator) || (this.txtNumber.SelectionStart != this.txtNumber.Text.Length))
                {
                    if (btnButton.Text.Equals(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator))
                    {
                        this.txtNumber.SelectionStart = this.txtNumber.Text.IndexOf(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator) + 1;
                    }
                    else
                    {
                        this.txtNumber.Text = this.txtNumber.Text.Substring(0, this.txtNumber.SelectionStart) + btnButton.Text + this.txtNumber.Text.Substring(this.txtNumber.SelectionStart);
                        if (flag || (this.txtNumber.Text.Substring(0, this.txtNumber.Text.IndexOf(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)).Length.Equals(1) && selectionStart.Equals(1)))
                        {
                            this.txtNumber.SelectionStart = selectionStart;
                        }
                        else
                        {
                            this.txtNumber.SelectionStart = selectionStart + 1;
                        }
                        if (this.txtNumber.Text.Substring(0, 2).Contains(NumberFormatInfo.CurrentInfo.NumberGroupSeparator) || (this.txtNumber.Text.Substring(0, 3).Contains(NumberFormatInfo.CurrentInfo.NumberGroupSeparator) && this.txtNumber.Text.Substring(0, 1).Contains("-")))
                        {
                            this.txtNumber.SelectionStart = selectionStart + 2;
                        }
                    }
                }
            }
        }

        private void btnButtonF02_Click(object sender, EventArgs e)
        {
            this.lblSign.Text = "";
            this.ib_CheckFunction = true;
            this.idec_CurrentNumber = 0M;
            this.txtNumber.Text = "0";
            this.txtNumber.SelectionStart = this.txtNumber.Text.IndexOf(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator);
        }

        private void btnButtonF09_Click(object sender, EventArgs e)
        {
            this.KeyFunction((Button) sender);
        }

        private void btnButtonF10_Click(object sender, EventArgs e)
        {
            this.KeyFunction((Button) sender);
        }

        private void btnButtonF11_Click(object sender, EventArgs e)
        {
            this.KeyFunction((Button) sender);
        }

        private void btnButtonF12_Click(object sender, EventArgs e)
        {
            this.KeyFunction((Button) sender);
        }

        private void btnButtonF13_Click(object sender, EventArgs e)
        {
            this.AllFunction("=");
        }

        private void btnButtonN00_Click(object sender, EventArgs e)
        {
            this.AnyKeyPressed((Button) sender);
        }

        private void btnButtonN01_Click(object sender, EventArgs e)
        {
            this.AnyKeyPressed((Button) sender);
        }

        private void btnButtonN02_Click(object sender, EventArgs e)
        {
            this.AnyKeyPressed((Button) sender);
        }

        private void btnButtonN03_Click(object sender, EventArgs e)
        {
            this.AnyKeyPressed((Button) sender);
        }

        private void btnButtonN04_Click(object sender, EventArgs e)
        {
            this.AnyKeyPressed((Button) sender);
        }

        private void btnButtonN05_Click(object sender, EventArgs e)
        {
            this.AnyKeyPressed((Button) sender);
        }

        private void btnButtonN06_Click(object sender, EventArgs e)
        {
            this.AnyKeyPressed((Button) sender);
        }

        private void btnButtonN07_Click(object sender, EventArgs e)
        {
            this.AnyKeyPressed((Button) sender);
        }

        private void btnButtonN08_Click(object sender, EventArgs e)
        {
            this.AnyKeyPressed((Button) sender);
        }

        private void btnButtonN09_Click(object sender, EventArgs e)
        {
            this.AnyKeyPressed((Button) sender);
        }

        private void btnButtonN10_Click(object sender, EventArgs e)
        {
            this.AnyKeyPressed((Button) sender);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            ////ComponentResourceManager manager = new ComponentResourceManager(typeof(FormCalculator));
            this.pnlTextbox = new Panel();
            this.txtNumber = new TextNumeric();
            this.lblMemo = new LabelControl();
            this.lblSign = new LabelControl();
            this.btnButtonF05 = new BtnControl();
            this.btnButtonF04 = new BtnControl();
            this.btnButtonF03 = new BtnControl();
            this.btnButtonF02 = new BtnControl();
            this.btnButtonF01 = new BtnControl();
            this.btnButtonN00 = new BtnControl();
            this.btnButtonN01 = new BtnControl();
            this.btnButtonN04 = new BtnControl();
            this.btnButtonN07 = new BtnControl();
            this.btnButtonF06 = new BtnControl();
            this.btnButtonN10 = new BtnControl();
            this.btnButtonN02 = new BtnControl();
            this.btnButtonN05 = new BtnControl();
            this.btnButtonN08 = new BtnControl();
            this.btnButtonF07 = new BtnControl();
            this.btnButtonF13 = new BtnControl();
            this.btnButtonN03 = new BtnControl();
            this.btnButtonN06 = new BtnControl();
            this.btnButtonN09 = new BtnControl();
            this.btnButtonF08 = new BtnControl();
            this.btnButtonF12 = new BtnControl();
            this.btnButtonF11 = new BtnControl();
            this.btnButtonF10 = new BtnControl();
            this.btnButtonF09 = new BtnControl();
            this.pnlTextbox.SuspendLayout();
            base.SuspendLayout();
            this.pnlTextbox.BackColor = Color.White;
            this.pnlTextbox.BorderStyle = BorderStyle.Fixed3D;
            this.pnlTextbox.Controls.Add(this.txtNumber);
            this.pnlTextbox.Controls.Add(this.lblMemo);
            this.pnlTextbox.Controls.Add(this.lblSign);
            this.pnlTextbox.Location = new Point(4, 3);
            this.pnlTextbox.Name = "pnlTextbox";
            this.pnlTextbox.Size = new Size(0xc7, 0x15);
            this.pnlTextbox.TabIndex = 0;
            this.txtNumber.BorderStyle = BorderStyle.None;
            this.txtNumber.Font = new Font("Arial", 8.25f);
            this.txtNumber.Location = new Point(20, 3);
            this.txtNumber.Name = "txtNumber";
            this.txtNumber.NumericPrecision = 1;
            this.txtNumber.NumericScaleOnFocus = 0;
            this.txtNumber.NumericScaleOnLostFocus = 0;
            int[] bits = new int[4];
            this.txtNumber.NumericValue = new decimal(bits);
            this.txtNumber.OldValue = null;
            this.txtNumber.Size = new Size(0xa3, 13);
            this.txtNumber.TabIndex = 1;
            this.txtNumber.TabStop = false;
            this.txtNumber.Text = "0";
            this.txtNumber.TextAlign = HorizontalAlignment.Right;
            this.txtNumber.UserTextNumericFormat = AppInstance.TextNumericFormat.Quantity;
//            //this.txtNumber.Value = null;//manager.GetObject("txtNumber.Value");
            this.txtNumber.ZeroIsShown = true;
            this.lblMemo.AutoSize = true;
            this.lblMemo.Font = new Font("Arial", 8.25f);
            this.lblMemo.Location = new Point(-1, -2);
            this.lblMemo.Name = "lblMemo";
            this.lblMemo.Size = new Size(0x15, 14);
            this.lblMemo.TabIndex = 4;
            this.lblMemo.Text = "M+";
            this.lblSign.Font = new Font("Arial", 8.25f);
            this.lblSign.Location = new Point(0xb8, 2);
            this.lblSign.Name = "lblSign";
            this.lblSign.Size = new Size(12, 14);
            this.lblSign.TabIndex = 3;
            this.btnButtonF05.Font = new Font("Arial", 8.25f);
            this.btnButtonF05.Location = new Point(4, 30);
            this.btnButtonF05.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF05.Name = "btnButtonF05";
            this.btnButtonF05.Size = new Size(0x27, 0x22);
            this.btnButtonF05.TabIndex = 1;
            this.btnButtonF05.Text = "MC";
            this.btnButtonF05.UseVisualStyleBackColor = true;
            this.btnButtonF04.Font = new Font("Arial", 8.25f);
            this.btnButtonF04.Location = new Point(4, 0x40);
            this.btnButtonF04.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF04.Name = "btnButtonF04";
            this.btnButtonF04.Size = new Size(0x27, 0x22);
            this.btnButtonF04.TabIndex = 6;
            this.btnButtonF04.Text = "5%";
            this.btnButtonF04.UseVisualStyleBackColor = true;
            this.btnButtonF03.Font = new Font("Arial", 8.25f);
            this.btnButtonF03.Location = new Point(4, 0x62);
            this.btnButtonF03.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF03.Name = "btnButtonF03";
            this.btnButtonF03.Size = new Size(0x27, 0x22);
            this.btnButtonF03.TabIndex = 11;
            this.btnButtonF03.Text = "&Sqrt";
            this.btnButtonF03.UseVisualStyleBackColor = true;
            this.btnButtonF02.Font = new Font("Arial", 8.25f);
            this.btnButtonF02.Location = new Point(4, 0x84);
            this.btnButtonF02.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF02.Name = "btnButtonF02";
            this.btnButtonF02.Size = new Size(0x27, 0x22);
            this.btnButtonF02.TabIndex = 0x10;
            this.btnButtonF02.Text = "&C";
            this.btnButtonF02.UseVisualStyleBackColor = true;
            this.btnButtonF02.Click += new EventHandler(this.btnButtonF02_Click);
            this.btnButtonF01.Font = new Font("Arial", 8.25f);
            this.btnButtonF01.Location = new Point(4, 0xa6);
            this.btnButtonF01.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF01.Name = "btnButtonF01";
            this.btnButtonF01.Size = new Size(0x27, 0x22);
            this.btnButtonF01.TabIndex = 0x15;
            this.btnButtonF01.Text = "&AC";
            this.btnButtonF01.UseVisualStyleBackColor = true;
            this.btnButtonN00.Font = new Font("Arial", 8.25f);
            this.btnButtonN00.Location = new Point(0x2c, 0xa6);
            this.btnButtonN00.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonN00.Name = "btnButtonN00";
            this.btnButtonN00.Size = new Size(0x27, 0x22);
            this.btnButtonN00.TabIndex = 0x16;
            this.btnButtonN00.Text = "0";
            this.btnButtonN00.UseVisualStyleBackColor = true;
            this.btnButtonN00.Click += new EventHandler(this.btnButtonN00_Click);
            this.btnButtonN01.Font = new Font("Arial", 8.25f);
            this.btnButtonN01.Location = new Point(0x2c, 0x84);
            this.btnButtonN01.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonN01.Name = "btnButtonN01";
            this.btnButtonN01.Size = new Size(0x27, 0x22);
            this.btnButtonN01.TabIndex = 0x11;
            this.btnButtonN01.Text = "1";
            this.btnButtonN01.UseVisualStyleBackColor = true;
            this.btnButtonN01.Click += new EventHandler(this.btnButtonN01_Click);
            this.btnButtonN04.Font = new Font("Arial", 8.25f);
            this.btnButtonN04.Location = new Point(0x2c, 0x62);
            this.btnButtonN04.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonN04.Name = "btnButtonN04";
            this.btnButtonN04.Size = new Size(0x27, 0x22);
            this.btnButtonN04.TabIndex = 12;
            this.btnButtonN04.Text = "4";
            this.btnButtonN04.UseVisualStyleBackColor = true;
            this.btnButtonN04.Click += new EventHandler(this.btnButtonN04_Click);
            this.btnButtonN07.Font = new Font("Arial", 8.25f);
            this.btnButtonN07.Location = new Point(0x2c, 0x40);
            this.btnButtonN07.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonN07.Name = "btnButtonN07";
            this.btnButtonN07.Size = new Size(0x27, 0x22);
            this.btnButtonN07.TabIndex = 7;
            this.btnButtonN07.Text = "7";
            this.btnButtonN07.UseVisualStyleBackColor = true;
            this.btnButtonN07.Click += new EventHandler(this.btnButtonN07_Click);
            this.btnButtonF06.Font = new Font("Arial", 8.25f);
            this.btnButtonF06.Location = new Point(0x2c, 30);
            this.btnButtonF06.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF06.Name = "btnButtonF06";
            this.btnButtonF06.Size = new Size(0x27, 0x22);
            this.btnButtonF06.TabIndex = 2;
            this.btnButtonF06.Text = "MR";
            this.btnButtonF06.UseVisualStyleBackColor = true;
            this.btnButtonN10.Font = new Font("Arial", 8.25f);
            this.btnButtonN10.Location = new Point(0x54, 0xa6);
            this.btnButtonN10.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonN10.Name = "btnButtonN10";
            this.btnButtonN10.Size = new Size(0x27, 0x22);
            this.btnButtonN10.TabIndex = 0x17;
            this.btnButtonN10.Text = ".";
            this.btnButtonN10.UseVisualStyleBackColor = true;
            this.btnButtonN10.Click += new EventHandler(this.btnButtonN10_Click);
            this.btnButtonN02.Font = new Font("Arial", 8.25f);
            this.btnButtonN02.Location = new Point(0x54, 0x84);
            this.btnButtonN02.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonN02.Name = "btnButtonN02";
            this.btnButtonN02.Size = new Size(0x27, 0x22);
            this.btnButtonN02.TabIndex = 0x12;
            this.btnButtonN02.Text = "2";
            this.btnButtonN02.UseVisualStyleBackColor = true;
            this.btnButtonN02.Click += new EventHandler(this.btnButtonN02_Click);
            this.btnButtonN05.Font = new Font("Arial", 8.25f);
            this.btnButtonN05.Location = new Point(0x54, 0x62);
            this.btnButtonN05.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonN05.Name = "btnButtonN05";
            this.btnButtonN05.Size = new Size(0x27, 0x22);
            this.btnButtonN05.TabIndex = 13;
            this.btnButtonN05.Text = "5";
            this.btnButtonN05.UseVisualStyleBackColor = true;
            this.btnButtonN05.Click += new EventHandler(this.btnButtonN05_Click);
            this.btnButtonN08.Font = new Font("Arial", 8.25f);
            this.btnButtonN08.Location = new Point(0x54, 0x40);
            this.btnButtonN08.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonN08.Name = "btnButtonN08";
            this.btnButtonN08.Size = new Size(0x27, 0x22);
            this.btnButtonN08.TabIndex = 8;
            this.btnButtonN08.Text = "8";
            this.btnButtonN08.UseVisualStyleBackColor = true;
            this.btnButtonN08.Click += new EventHandler(this.btnButtonN08_Click);
            this.btnButtonF07.Font = new Font("Arial", 8.25f);
            this.btnButtonF07.Location = new Point(0x54, 30);
            this.btnButtonF07.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF07.Name = "btnButtonF07";
            this.btnButtonF07.Size = new Size(0x27, 0x22);
            this.btnButtonF07.TabIndex = 3;
            this.btnButtonF07.Text = "M-";
            this.btnButtonF07.UseVisualStyleBackColor = true;
            this.btnButtonF13.Font = new Font("Arial", 8.25f);
            this.btnButtonF13.Location = new Point(0x7c, 0xa6);
            this.btnButtonF13.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF13.Name = "btnButtonF13";
            this.btnButtonF13.Size = new Size(0x27, 0x22);
            this.btnButtonF13.TabIndex = 0x18;
            this.btnButtonF13.Text = "=";
            this.btnButtonF13.UseVisualStyleBackColor = true;
            this.btnButtonF13.Click += new EventHandler(this.btnButtonF13_Click);
            this.btnButtonN03.Font = new Font("Arial", 8.25f);
            this.btnButtonN03.Location = new Point(0x7c, 0x84);
            this.btnButtonN03.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonN03.Name = "btnButtonN03";
            this.btnButtonN03.Size = new Size(0x27, 0x22);
            this.btnButtonN03.TabIndex = 0x13;
            this.btnButtonN03.Text = "3";
            this.btnButtonN03.UseVisualStyleBackColor = true;
            this.btnButtonN03.Click += new EventHandler(this.btnButtonN03_Click);
            this.btnButtonN06.Font = new Font("Arial", 8.25f);
            this.btnButtonN06.Location = new Point(0x7c, 0x62);
            this.btnButtonN06.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonN06.Name = "btnButtonN06";
            this.btnButtonN06.Size = new Size(0x27, 0x22);
            this.btnButtonN06.TabIndex = 14;
            this.btnButtonN06.Text = "6";
            this.btnButtonN06.UseVisualStyleBackColor = true;
            this.btnButtonN06.Click += new EventHandler(this.btnButtonN06_Click);
            this.btnButtonN09.Font = new Font("Arial", 8.25f);
            this.btnButtonN09.Location = new Point(0x7c, 0x40);
            this.btnButtonN09.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonN09.Name = "btnButtonN09";
            this.btnButtonN09.Size = new Size(0x27, 0x22);
            this.btnButtonN09.TabIndex = 9;
            this.btnButtonN09.Text = "9";
            this.btnButtonN09.UseVisualStyleBackColor = true;
            this.btnButtonN09.Click += new EventHandler(this.btnButtonN09_Click);
            this.btnButtonF08.Font = new Font("Arial", 8.25f);
            this.btnButtonF08.Location = new Point(0x7c, 30);
            this.btnButtonF08.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF08.Name = "btnButtonF08";
            this.btnButtonF08.Size = new Size(0x27, 0x22);
            this.btnButtonF08.TabIndex = 4;
            this.btnButtonF08.Text = "M+";
            this.btnButtonF08.UseVisualStyleBackColor = true;
            this.btnButtonF12.Font = new Font("Arial", 8.25f);
            this.btnButtonF12.Location = new Point(0xa4, 0x84);
            this.btnButtonF12.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF12.Name = "btnButtonF12";
            this.btnButtonF12.Size = new Size(0x27, 0x44);
            this.btnButtonF12.TabIndex = 20;
            this.btnButtonF12.Text = "+";
            this.btnButtonF12.UseVisualStyleBackColor = true;
            this.btnButtonF12.Click += new EventHandler(this.btnButtonF12_Click);
            this.btnButtonF11.Font = new Font("Arial", 8.25f);
            this.btnButtonF11.Location = new Point(0xa4, 0x62);
            this.btnButtonF11.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF11.Name = "btnButtonF11";
            this.btnButtonF11.Size = new Size(0x27, 0x22);
            this.btnButtonF11.TabIndex = 15;
            this.btnButtonF11.Text = "-";
            this.btnButtonF11.UseVisualStyleBackColor = true;
            this.btnButtonF11.Click += new EventHandler(this.btnButtonF11_Click);
            this.btnButtonF10.Font = new Font("Arial", 8.25f);
            this.btnButtonF10.Location = new Point(0xa4, 0x40);
            this.btnButtonF10.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF10.Name = "btnButtonF10";
            this.btnButtonF10.Size = new Size(0x27, 0x22);
            this.btnButtonF10.TabIndex = 10;
            this.btnButtonF10.Text = "x";
            this.btnButtonF10.UseVisualStyleBackColor = true;
            this.btnButtonF10.Click += new EventHandler(this.btnButtonF10_Click);
            this.btnButtonF09.Font = new Font("Arial", 8.25f);
            this.btnButtonF09.Location = new Point(0xa4, 30);
            this.btnButtonF09.Margin = new Padding(3, 3, 0, 0);
            this.btnButtonF09.Name = "btnButtonF09";
            this.btnButtonF09.Size = new Size(0x27, 0x22);
            this.btnButtonF09.TabIndex = 5;
            this.btnButtonF09.Text = "\x00f7";
            this.btnButtonF09.UseVisualStyleBackColor = true;
            this.btnButtonF09.Click += new EventHandler(this.btnButtonF09_Click);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.ClientSize = new Size(0xcf, 0xcc);
            base.Controls.Add(this.btnButtonF12);
            base.Controls.Add(this.btnButtonF11);
            base.Controls.Add(this.btnButtonF10);
            base.Controls.Add(this.btnButtonF09);
            base.Controls.Add(this.btnButtonF13);
            base.Controls.Add(this.btnButtonN03);
            base.Controls.Add(this.btnButtonN06);
            base.Controls.Add(this.btnButtonN09);
            base.Controls.Add(this.btnButtonF08);
            base.Controls.Add(this.btnButtonN10);
            base.Controls.Add(this.btnButtonN02);
            base.Controls.Add(this.btnButtonN05);
            base.Controls.Add(this.btnButtonN08);
            base.Controls.Add(this.btnButtonF07);
            base.Controls.Add(this.btnButtonN00);
            base.Controls.Add(this.btnButtonN01);
            base.Controls.Add(this.btnButtonN04);
            base.Controls.Add(this.btnButtonN07);
            base.Controls.Add(this.btnButtonF06);
            base.Controls.Add(this.btnButtonF01);
            base.Controls.Add(this.btnButtonF02);
            base.Controls.Add(this.btnButtonF03);
            base.Controls.Add(this.btnButtonF04);
            base.Controls.Add(this.btnButtonF05);
            base.Controls.Add(this.pnlTextbox);
            //base.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            //base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "FormCalculator";
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.Manual;
            this.Text = "Calculator";
            base.TopMost = true;
            this.pnlTextbox.ResumeLayout(false);
            this.pnlTextbox.PerformLayout();
            base.ResumeLayout(false);
        }

        private void KeyFunction(Button btnButton)
        {
            this.AllFunction(this.lblSign.Text);
            this.lblSign.Text = btnButton.Text;
        }

        protected override void OnHandleDestroyed(EventArgs e)
        {
            this.ib_Disposed = true;
            base.OnHandleDestroyed(e);
        }

        protected override void OnVisibleChanged(EventArgs e)
        {
            AppInstance.CalculatorTopPosition = base.Top;
            AppInstance.CalculatorLeftPosition = base.Left;
            AppInstance.OnSave();
            base.OnVisibleChanged(e);
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if ((msg.Msg == 0x100) && ((keyData == Keys.NumPad0) || (keyData == Keys.D0)))
            {
                this.AnyKeyPressed(this.btnButtonN00);
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.NumPad1) || (keyData == Keys.D1)))
            {
                this.AnyKeyPressed(this.btnButtonN01);
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.NumPad2) || (keyData == Keys.D2)))
            {
                this.AnyKeyPressed(this.btnButtonN02);
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.NumPad3) || (keyData == Keys.D3)))
            {
                this.AnyKeyPressed(this.btnButtonN03);
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.NumPad4) || (keyData == Keys.D4)))
            {
                this.AnyKeyPressed(this.btnButtonN04);
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.NumPad5) || (keyData == Keys.D5)))
            {
                this.AnyKeyPressed(this.btnButtonN05);
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.NumPad6) || (keyData == Keys.D6)))
            {
                this.AnyKeyPressed(this.btnButtonN06);
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.NumPad7) || (keyData == Keys.D7)))
            {
                this.AnyKeyPressed(this.btnButtonN07);
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.NumPad8) || (keyData == Keys.D8)))
            {
                this.AnyKeyPressed(this.btnButtonN08);
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.NumPad9) || (keyData == Keys.D9)))
            {
                this.AnyKeyPressed(this.btnButtonN09);
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.Divide) || (keyData == Keys.OemQuestion)))
            {
                this.KeyFunction(this.btnButtonF09);
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.Multiply) || (keyData == (Keys.Shift | Keys.D8))))
            {
                this.KeyFunction(this.btnButtonF10);
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.Subtract) || (keyData == Keys.OemMinus)))
            {
                this.KeyFunction(this.btnButtonF11);
                return true;
            }
            if ((msg.Msg == 0x100) && ((keyData == Keys.Add) || (keyData == (Keys.Shift | Keys.Oemplus))))
            {
                this.KeyFunction(this.btnButtonF12);
            }
            else
            {
                if ((msg.Msg == 0x100) && (keyData == Keys.Back))
                {
                    this.txtNumber.BackColor = Color.White;
                    this.txtNumber.ForeColor = Color.Black;
                    int selectionStart = this.txtNumber.SelectionStart;
                    if (selectionStart != 0)
                    {
                        if (!this.txtNumber.Text.Substring(this.txtNumber.SelectionStart - 1, 1).Contains(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator))
                        {
                            if (this.txtNumber.Text.Substring(0, 2).Contains(NumberFormatInfo.CurrentInfo.NumberGroupSeparator) || (this.txtNumber.Text.Substring(0, 3).Contains(NumberFormatInfo.CurrentInfo.NumberGroupSeparator) && this.txtNumber.Text.Substring(0, 1).Contains("-")))
                            {
                                selectionStart--;
                            }
                            this.txtNumber.Text = this.txtNumber.Text.Substring(0, selectionStart - 1) + this.txtNumber.Text.Substring(selectionStart);
                            if (selectionStart != 1)
                            {
                                this.txtNumber.SelectionStart = selectionStart - 1;
                            }
                        }
                        else
                        {
                            this.txtNumber.SelectionStart = selectionStart - 1;
                        }
                    }
                    return true;
                }
                if ((msg.Msg == 0x100) && ((keyData == Keys.Return) || (keyData == Keys.Oemplus)))
                {
                    if (this.lblSign.Text.Equals(string.Empty))
                    {
                        this.SetActiveValue(this.txtNumber.Value);
                        base.Hide();
                    }
                    else
                    {
                        this.AllFunction("=");
                    }
                    return true;
                }
                if ((msg.Msg == 0x100) && (keyData == Keys.Escape))
                {
                    base.Hide();
                    return true;
                }
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

        private void SetActiveValue(object po_Value)
        {
            if (this.CurrentControl is DataGridView)
            {
                if (!(this.CurrentControl as DataGridView).CurrentCell.ReadOnly)
                {
                    (this.CurrentControl as DataGridView).CurrentCell.Value = po_Value;
                    (this.CurrentControl as DataGridView).BeginEdit(false);
                    (this.CurrentControl as DataGridView).EndEdit();
                }
            }
            else if ((this.CurrentControl is TextBox) && !(this.CurrentControl as TextBox).ReadOnly)
            {
                (this.CurrentControl as TextBox).Text = po_Value.ToString();
            }
        }

        public void SetTextValue(object po_Value)
        {
            if (po_Value != null)
            {
                try
                {
                    this.ib_CheckFunction = false;
                    this.txtNumber.NumericValue = Convert.ToDecimal(po_Value);
                }
                catch
                {
                }
            }
        }

        public object CurrentControl
        {
            get
            {
                return this.oCurrentControl;
            }
            set
            {
                this.oCurrentControl = value;
            }
        }

        public decimal CurrentNumber
        {
            get
            {
                return this.idec_CurrentNumber;
            }
            set
            {
                this.idec_CurrentNumber = value;
            }
        }

        public decimal MemoryNumber
        {
            get
            {
                return this.idec_MemoryNumber;
            }
            set
            {
                this.idec_MemoryNumber = value;
            }
        }
    }
}

